home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DEMOS / OTLIGHT.ZIP / FORMULAS.TXT < prev    next >
Encoding:
Text File  |  1996-10-18  |  1.2 KB  |  44 lines

  1.  
  2.  Hello there!
  3.  
  4.  Vulture here... Just for convinience, I've stated the primairy formulas and
  5.  definitions in a seperate file. I had a hard time understanding this math
  6.  and writing these things down proved to be quite helpfull.
  7.  
  8. ──────────────────────────────────────────────────────────────────────────────
  9.  
  10.  Vector definitions:
  11.  
  12.    V1 = P2 - P1    (x2-x1,y2-y1,z2-z1)
  13.    V2 = P3 - P1    (x3-x1,y3-y1,z3-z1)
  14.  
  15.  Crossproduct:
  16.  
  17.    V3 = V1 * V2 = (y1*z2-y2*z1, z1*x2-z2*x1, x1*y2-x2*y1)
  18.  
  19.  Set length vector to 1:
  20.  
  21.    V3 = V3 / sqrt(x*x+y*y+z*z)
  22.  
  23.  Dotproduct:
  24.  
  25.    D = V1 * V2 = (x1*x2)+(y1*y2)+(z1*z2)
  26.  
  27.  Lightvector (defined by you):
  28.  
  29.    L = (0,0,-1)
  30.  
  31. ──────────────────────────────────────────────────────────────────────────────
  32.  
  33.  First we define some vectors to do our calculations with. Secondly we
  34.  take the crossproduct of those vectors which returns a vector which is
  35.  at 90 degrees to the poly. The lenght of the vector must then be set to 1.
  36.  
  37.  Also, a socalled lightvector is defined. If the light is coming from
  38.  behind us, this vector would be like stated above.
  39.  
  40.  To find the color of the polygon we take the dotproduct of the normal
  41.  we just calculated and the lightvector. Goodluck!
  42.  
  43.        -Vulture/OT-
  44.